package com.example.framework.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.framework.R;
import com.moxun.tagcloudlib.view.TagsAdapter;

import java.util.List;

/**
 * @author:0.2℃
 * @date： 2022-04-04 15:54
 * @Description ：3D 星球适配器
 */
public class CloudTagAdapter extends TagsAdapter {
    private Context mContext;
    private List<String> mData;
    private LayoutInflater inflater;

    public CloudTagAdapter(Context mContext, List<String> mData) {
        this.mContext = mContext;
        this.mData = mData;
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public View getView(Context context, int position, ViewGroup parent) {
        // 初始化view
        View view = inflater.inflate(R.layout.layout_view_shape_item, null);
        // 初始化控件
        ImageView iv_star_icon = view.findViewById(R.id.iv_star_icon);
        TextView tv_star_name = view.findViewById(R.id.tv_star_name);
        // 赋值
        tv_star_name.setText(mData.get(position));
        switch (position % 10) {
            default:
                iv_star_icon.setImageResource(R.drawable.img_guide_star_1);
                break;
        }
        return view;
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public int getPopularity(int position) {
        return 7;
    }

    @Override
    public void onThemeColorChanged(View view, int themeColor) {

    }
}
